﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MTK_BieuThuc
{

    public class ConstExpr : Expression
    {
        private static class ZeroCreator
        {
            public static ConstExpr zero=new ConstExpr(0);
        }
        private double val;
        private ConstExpr(double v)
        {
            val = v;
        }
        public static ConstExpr createObject(double v)
        {
            if(v==0)
                return ZeroCreator.zero;
            return new ConstExpr(v);
        }
        public override double Evuluate(double x)
        {

            return val;
        }
        public override Expression derive()
        {
            return new ConstExpr(0);
        }
        public override string toString(StrategyString ss)
        {
            return(" "+val.ToString()+" ");
        }
    }
}
